<extend name="Public/base"/>
<block name="header">

</block>
<block name="body">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
   <div class="main-title">
       <h2>{:isset($info['id'])?'编辑':'新增'}轮播图片</h2>
   </div>
   <form action="{:U()}" method="post" class="form-horizontal">

       <div class="form-item">
           <label class="item-label">标题:<span class="check-tips"></span></label>
           <div class="controls">
               <input type="text" class="text input-small" name="title" value="{$info.title|default=''}">
           </div>
       </div>
       <div class="form-item">
           <label class="item-label">图片上传<span class="check-tips"></span></label>
           <div class="controls" id="up_header_img" >
               <input type="file" id="upload_file">

           </div>
           <input type="hidden" name="path" value=""/>
       </div>
       <div class="form-item">
           <button class="btn submit-btn ajax-post"  type="submit" target-form="form-horizontal">确 定</button>
           <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
       </div>
   </form>
</block>
<block name="script">
    <script type="text/javascript">
        //上传图片
        /* 初始化上传插件 */
        $("#upload_file").uploadify({
            "height"          : 30,
            "swf"             : "__STATIC__/uploadify/uploadify.swf",
            "fileObjName"     : "download",
            "buttonText"      : "上传图片",
            "uploader"        : "{:U('Banner/uploadPicture')}",
            "width"           : 120,
            'removeTimeout'   : 1,
            'fileTypeExts'    : '*.jpg; *.png; *.gif;',
            "onUploadSuccess" : uploadPicturecover_id,
            'onFallback' : function() {
                alert('未检测到兼容版本的Flash.');
            }
        });
        function uploadPicturecover_id(file, data){
            var data = $.parseJSON(data);
            if (data.status == 0) {
                alert('上传图片不能超过5M');
                return false
            }
            alert(data.info);
            $("#up_header_img").html('<img src="'+data.path+'" style="width: 100px; height: 100px;"/>');
            $("input[name=path]").val(data.path);

        }
    </script>
</block>
